package String.StringDemo;

import java.util.Scanner;

public class login {
    public static void main(String[] args) {
        String rightUsername="zhangsan";
        String rightPassword="123456";

        // 键盘录入用户名和密码
        Scanner sc=new Scanner(System.in);
        for(int i=0;i<3;i++){
            System.out.println("请输入用户名");
            String username=sc.next();
            System.out.println("请输入密码");
            String password=sc.next();
            if(username.equals(rightUsername)&&password.equals(rightPassword)){
                System.out.println("用户名和密码正确");
                break;
            }else{
                if(i==2){
                    System.out.println("账户"+username+"已被锁定,请联系客服或管理员解决问题");
                }else{
                    System.out.println("用户名或密码错误");

                }
            }
        }
    }
}
